﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Layout : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["TenDangNhap"] != null) // da dang nhap
            {
                login.Visible = false;
                signup.Visible = false;

                // hien thi ten dang nhap
                lblUsername.Text = Session["TenDangNhap"].ToString();
                lblXinchao.Visible = true;
                lblUsername.Visible = true;
                logout.Visible = true;

            }
            else
            {
                // da dang nhap
                login.Visible = true;
                signup.Visible = true;

                lblXinchao.Visible = false;
                lblUsername.Visible = false;
                logout.Visible = false;
            }
        }
    }

    // nut dang xuat
    protected void logout_Click(object sender, EventArgs e)
    {
        Session["TenDangNhap"] = null;
        Session["LanTruyCapCuoi"] = null;
        Session["IDThanhVien"] = null;

        Response.Redirect("index.aspx");
    }

}
